package com.easylinkin.linkappapi.quality.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.easylinkin.linkappapi.quality.dto.*;
import com.easylinkin.linkappapi.quality.entity.QualityQuestionInfo;
import com.easylinkin.linkappapi.quality.entity.vo.QualityQuestionInfoVo;
import com.easylinkin.linkappapi.quality.entity.vo.QualityScreenPageVo;
import org.apache.ibatis.annotations.Param;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * QualityQuestionInfo表数据库访问层
 *
 * @author zhengwen
 * @date 2022/08/16
 */
public interface QualityQuestionInfoMapper extends BaseMapper<QualityQuestionInfo> {


    /**
     * 查询分页
     *
     * @param page        分页参数对象
     * @param appQualityQuestionInfo 过滤参数对象
     * @return 查询分页结果
     */
    IPage<QualityQuestionInfo> selectPage(Page page, @Param("appQualityQuestionInfo") QualityQuestionInfo appQualityQuestionInfo);

    /**
     * 查询单条
     *
     * @param id 主键id
     * @return 查询结果
     */
    QualityQuestionInfo getOneById(@Param("id") Serializable id);

    /**
     * @Description: 质量问题分类统计
     * @author kan yuanfeng
     * @date 2020/11/04 11:42
     */
    List<QualityScreenDTO> getByProblemType(QualityScreenDTO qualityScreenDTO);

    /**
     * 查询dto数据
     * @param page page对象
     * @param questionInfoVo 条件vo
     * @return dto数据page
     */
    IPage<QualityQuestionInfoDto> selectDtoPage(Page page, QualityQuestionInfoVo questionInfoVo);

    List<QualityQuestionInfoVo> getBySubOrg(String tenantId);

    List<QualityScreenDTO> getByMonth(String tenantId);

    /**
     * 根据id查询dto信息
     * @param id 主键
     * @return 问题dto信息
     */
    QualityQuestionInfoDto selectDtoOne(Long id);

    /**
     * 根据条件查询数据按照状态分类统计数量
     * @param questionInfoVo 条件vo
     * @return 数量map
     */
    List<Map<String, Object>> countNumByState(QualityQuestionInfoVo questionInfoVo);

  IPage<QualityQuestionInfoDto> findAccountList(Page page, @Param("dto") QualityQuestionInfoDto questionInfoDto);

  IPage<QualityQuestionInfoDto> findOpenApiAccountList(Page page, @Param("dto") QualityQuestionInfoDto questionInfoDto);

  IPage<QualityQuestionPhotoAlbumDTO> selectPhotoAlbumByPage(Page page, @Param("photoAlbumQueryDTO") QualityQuestionPhotoAlbumQueryDTO photoAlbumQueryDTO);

  List<QualityQuestionPhotoAlbumDTO> selectPhotoAlbumByPage(@Param("photoAlbumQueryDTO") QualityQuestionPhotoAlbumQueryDTO photoAlbumQueryDTO);

  IPage<QualityQuestionStatisticsBySubOrgDTO> countQualityQuestionBySubOrg(Page page, @Param("queryDTO") QualityQuestionStatisticsQueryDTO queryDTO);

  IPage<QualityQuestionStatisticsByProblemTypeDTO> countQualityQuestionByProblemType(Page page, @Param("queryDTO") QualityQuestionStatisticsQueryDTO queryDTO);

  IPage<QualityQuestionStatisticsByCheckPartDTO> countQualityQuestionByCheckPart(Page page, @Param("queryDTO") QualityQuestionStatisticsQueryDTO queryDTO);


  Integer getCount(@Param("dto") QualityQuestionInfoDto questionInfoDto);

    /**
     * 根据条件查询质量趋势数据
     * 问题 + 检查
     * @param qualityScreenPageVo 条件vo
     * @return 统计数据
     */
    List<Map<String, Object>> selectQualityCheckTrend(QualityScreenPageVo qualityScreenPageVo);
    /**
     * 检查分析-根据一级名称分类统计
     * @param qualityScreenPageVo 条件vo
     * @return 统一出参
     */
    List<Map<String, Object>> countByFirstLevelProblemName(QualityScreenPageVo qualityScreenPageVo);

    /**
     * 分包单位问题统计数据
     * @param qualityScreenPageVo 条件vo
     * @return 统一出参
     */
    List<Map<String, Object>> questionCountGroupByLabor(QualityScreenPageVo qualityScreenPageVo);

  List<QualityQuestionStatisticsDTO> getOpenApiCount(@Param("qualityQuestionInfoDto") QualityQuestionInfoDto qualityQuestionInfoDto);

  List<QualityQuestionInfoDto> findList(@Param("qualityQuestionInfoDto") QualityQuestionInfoDto questionInfoDto);

  List<QualityQuestionStatisticsDTO> getOpenApiCheckNumCount(@Param("qualityQuestionInfoDto") QualityQuestionInfoDto qualityQuestionInfoDto);

  //查询已超期的质量隐患
  List<QualityQuestionInfoDto> findOverByTenantIds(@Param("tenantIds") List<String> tenantIds);

  //即将复合即将超期的数据
  List<QualityQuestionInfoDto> findHueList();

  // 质量检查分析-问题分类统计
    List<QuestionClassDTO> queClassStatis(QuestionClassQueryDTO dto);

    List<ProjectQuestionDTO> projectQuestionStatis(QuestionClassQueryDTO dto);

}

